<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.saltfish.appengine.worktable.datastore.Work"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.TreeMap"%>

<%
	request.setCharacterEncoding("UTF-8");
	String title = (String)request.getAttribute("title");
	String authUrl = (String)request.getAttribute("authUrl");
	String authBtn = (String)request.getAttribute("authBtn");
	Boolean isUser = (Boolean)request.getAttribute("isUser");
	String selYm = (String)request.getAttribute("selYm");
	String selYmJp = selYm.substring(0,4) + "年" + selYm.substring(5) + "月";
	String result = (String)request.getAttribute("result");
 %>
<!DOCTYPE html> 
<html> 
	<head> 
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title><%=title%></title> 
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<link rel="apple-touch-icon" href="/images/calendar.png"/> 
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
	<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
    <script>
 		$(document).ready(function(){
    		$("#info").live('click', function(event){
 				$.mobile.pageLoading();
			});
		});
	</script>     
</head> 
<body>
    <div data-role="page" id="page_main" >
        <div data-role="header"  data-theme="a" data-position="inline">
			<h1><%=title%></h1>
<% if (isUser) { %>
			<a href="/admin/edit?id=-1" data-icon="plus" data-role="button">今日</a>
<% } %>
	        <a href="/calendar?selYm=<%=selYm%>" data-role="button" data-icon="grid" class="ui-btn-right" data-transition="pop"><%=selYmJp%></a>
        </div>
        <div data-role="content" >
        	<ul data-role="listview" data-inset="true" data-dividertheme="a" data-counttheme="b" > 
 <%if (isUser && result != null) {%>
        	<li data-role="list-divider"><%=result%></li> 
 <%}%>
<%
	List<Work> workTable = (List<Work>)request.getAttribute("workTable");
	for (Work work : workTable) {
		if (isUser) {
%>
			<li>
				<a href="/admin/edit?id=<%=work.getId()%>&date=<%=work.getYmd()%>" data-transition="pop">
					<span style="<%=work.getFontColor()%>"><h3><%=work.getYmdByJp()%></h3></span>
<%if (work.getResultTime() != null) {%>
					<p><%=work.getStartTime()%>～<%=work.getEndTime()%></p>
<%}%>
<%if (work.getComment() != null) {%>
					<p><%=work.getComment()%></p>
<%}%>
				</a>
<%if (work.getResultTime() != null) {%>
				<span class="ui-li-count"><%=work.getResultTime()%></span>
<%}%>
<%if ("on".equals(work.getHoliday())) {%>
				<span class="ui-li-count">休み</span>
<%}%>
			</li> 
<%
		} else {
%>
			<li><span style="<%=work.getFontColor()%>"><%=work.getYmdByJp()%></span></li> 
<%
		}
%>
<%}%>   
			</ul> 	
		</div>
		<div data-role="footer" data-position="inline" data-theme="a">
			<div data-role="navbar">
				<ul>
			        <li><a href="<%= authUrl %>" rel="external" data-role="button" data-icon="arrow-r"><%=authBtn%></a></li>
<% if (isUser) { %>
					<li><a href="/admin/edit?id=-1" data-transition="pop" data-icon="plus" data-role="button">今日</a></li>
<%}%>   
					<li><a href="/info?selYm=<%=selYm%>" id="info" data-icon="info" data-role="button" rel="external">情報</a></li>
				</ul>
			</div>
		</div>
	</div>
</body>
</html>
